package com.cavy.platform.server.mapper;

import com.cavy.platform.server.domain.GitRemotePipeline;
import com.cavy.platform.server.dto.GitRemotePipelineCreateDto;
import com.cavy.platform.server.dto.GitRemotePipelineDto;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * @author 唐旭
 * @Date 2018/7/17
 */
@Mapper
public interface GitRemotePipelineMapper {
    GitRemotePipelineMapper INSTANCE = Mappers.getMapper(GitRemotePipelineMapper.class);

    @Mapping(target = "project.workSpace", source = "project.workSpace.name")
    GitRemotePipelineDto toDto(GitRemotePipeline pipeline);

    @Mapping(target = "project.name", source = "projectName")
    @Mapping(target = "project.workSpace.name", source = "workspace")
    GitRemotePipeline convert(GitRemotePipelineCreateDto dto);
}
